const webSocketServer = require('ws').Server;
wss = new webSocketServer({ port: 8080 });
wss.on('connection', function (ws) {
  console.log('开始连接');
  console.log(ws);

  ws.on('message', function (message) {  //监听了message 事件
    console.log(message);
    setInterval(() => {
      ws.send(JSON.stringify(

        {
          "orderType": "ParkingFee",
          "payType": "alipay",
          "totalFee": `${message}`,
          "orderId": "6348189068815237120",
          "params": {
            "pid": 160,
            "pnid": "21",
            "plateNumber": {
              "id": 21,
              "plateNumberPrefix": "陕A",
              "plateNumberSuffix": "AB123",
              "engineNumber": "",
              "vin": ""
            }
          }
        }

      ));
    }, 20000)

  });
});

console.log(`SocketServer listen on port 8080`);